package com.szxy.content.controller;

import com.szxy.content.service.ContentCategoryService;
import com.szxy.pojo.TbContentCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther:zwer
 * @Date:2019/9/9 21:21
 * @Description:com.szxy.content.controller
 * @Version:1.0
 **/
@RestController
@RequestMapping("/service/contentCategory")
public class ContentCategoryController {

    @Autowired
    private ContentCategoryService contentCategoryService;

    /**
     * 查询内容分类目录
     * @param id 内容分类父 ID
     * @return
     */
    @GetMapping("/selectContentCategoryByParentId")
    List<TbContentCategory> selectContentCategoryByParentId(@RequestParam  Long id){
        return this.contentCategoryService.selectContentCategoryByParentId(id);
    }

    /**
     * 添加内容分类目录
     * @param contentCategory
     * @return
     */
    @PostMapping("/insertContentCategory")
    int insertContentCategory(@RequestBody TbContentCategory contentCategory){
        return this.contentCategoryService.insertContentCategory(contentCategory);
    }

    /**
     * 更新节点信息
     * @param tbContentCategory
     * @return
     */
    @PostMapping("/updateContentCategoryById")
    Integer updateContentCategoryById(@RequestBody TbContentCategory tbContentCategory){
        return this.contentCategoryService.updateContentCategoryById(tbContentCategory);
    }

    /**
     * 删除节点信息
     * @param categoryId
     * @return
     */
    @GetMapping("/deleteContentCategoryById")
    Integer deleteContentCategoryById(@RequestParam("categoryId") Long categoryId){
        return this.contentCategoryService.deleteContentCategoryById(categoryId);
    }
}
